#ifndef TESTER_TEST_CASE_H_
#define TESTER_TEST_CASE_H_

#include <cassert>

#include "exceptions.h"
#include "result.h"

#include "testmethod.h"
#include "test.h"
#include "globalsuite.h"

namespace Tester {
   template<class T>
   class TestCase : public Test {
      protected:
         void add(const char *name, void (T:: *testMethod)()) {
            Test::add(new TestMethodMember<T>(name, testMethod));
         }

         template<class E>
         void assertThrow(void (T:: *test)(), int line = -1) {
            if(test == 0) 
               throw CriticalError("AssertThrow Error (the test-method is NULL)");

            try {
               (static_cast<T*>(this)->*test)();

            }catch(const E &e) {
               return ;
            }catch( ... ) {
               throw AssertFail("AssertThrow - UnexpectedException", line);
            }

            throw AssertFail("AssertThrow - NoException", line);
         }

      public:
         TestCase(const char *name, const char *file = 0) : Test(name, file) {}
   };
}
#endif
